/**
 * 流程名称区
*/
// import Item from "antd/lib/list/Item";
import { useRequest, useUpdate } from "ahooks";
import React, { Suspense, useEffect, useState } from "react";
import { useForm } from "../../framework/common/context/metadata-context";


const InitiateForm = React.lazy(() => import("./InitiateForm"));//发起表单
const ApproveForm = React.lazy(() => import("./ApproveForm"));//审批表单
/**
 * toggleFooter 父组件方法，用于发起时，控制表单内容显示隐藏
 */
export default function ({ toggleFooter,hideFooter }) {
    const { data: tplData, urlPrefix, params} = useForm().root;
    if(tplData.ApproveButtons === undefined){
        console.warn("缺少审批按钮信息：tplData.ApproveButtons");
        return null;
    }

    if(tplData.ApproveButtons.length <= 0){//没有审批按钮，查看模式
        return null;
    }

    // console.log('!params.IsSubProc ', !params.IsSubProc)
    // if(tplData.ApproveButtons.length === 1 && params.IsSubProc && InitapproveType == "Initiate") {//如果是发起步骤，且是子流程
    //     InitapproveType = "";//置为空
    //     console.warn("只有一个按钮，且是子流程，不渲染审批表单");
    //     return null;
    // }
    let approveType = tplData.ApproveButtons[0].OperationCode;//审批状态，默认为发起

    if(tplData.ApproveSteps.length){//存在审批步骤，就是审批中
        //审批中表单
        return <Suspense fallback={null}>
            <ApproveForm></ApproveForm>
        </Suspense>
        
    }else{
        //发起时表单
        return <Suspense fallback={null}>
            <InitiateForm approveType={approveType} toggleFooter={toggleFooter} hideFooter={hideFooter}></InitiateForm>
        </Suspense>
    }
}